package com.example.gausspaper.service;

import com.example.gausspaper.domain.Paper;
import com.example.gausspaper.repository.PaperRepository;
import com.example.gausspaper.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PaperService {
    @Autowired
    private PaperRepository paperRepository;

    public void addPaper(Paper newpaper, List<String> tags){
        String paper_id = newpaper.getPaperId();
        paperRepository.save(newpaper);
        paperRepository.addPaperUseDataset(paper_id,newpaper.getDatasetNames(),newpaper.getTitle());
        for (int i = 0; i < tags.size(); i++) {
            paperRepository.addPaperHasTag(paper_id,tags.get(i));
        }
    }
}
